package com.oa.admin.service.impl;

import com.joneying.common.annotation.CommonService;
import com.oa.core.PageResult;
import com.oa.admin.entity.HouseCheckRecording;
import com.oa.admin.mapper.HouseCheckRecordingMapper;
import com.oa.admin.service.IHouseCheckRecordingService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;

/**
 * <p>
 * 房租租赁入住记录表 服务实现类
 * </p>
 *
 * @author syb123
 * @since 2019-02-22
 */
@Service
public class HouseCheckRecordingServiceImpl extends ServiceImpl<HouseCheckRecordingMapper, HouseCheckRecording> implements IHouseCheckRecordingService {

    private final HouseCheckRecordingMapper houseCheckRecordingMapper;

    @Autowired
    public HouseCheckRecordingServiceImpl(HouseCheckRecordingMapper houseCheckRecordingMapper) {
        this.houseCheckRecordingMapper = houseCheckRecordingMapper;
    }

    @Override
    @CommonService
    public PageResult<HouseCheckRecording> findList(Integer pageNum, Integer pageSize) {
        if(pageNum == null){
            List<HouseCheckRecording> list = houseCheckRecordingMapper.findList();
            return new PageResult<>(list);
        }else{
            // 当前页，总条数 构造 page 对象
            Page<HouseCheckRecording> page = new Page<>(pageNum, pageSize);
            //查询
            List<HouseCheckRecording> list = houseCheckRecordingMapper.findList(page);
            return new PageResult<>(list);
        }
    }

    /**
    * 根据id查询
    */
    @Override
    @CommonService
    public HouseCheckRecording findHouseCheckRecordingById(String id){
        return houseCheckRecordingMapper.findById(id);
    }
}
